package it.tukano.swingdeco.menubar;

import it.tukano.swingdeco.ExtUtilities;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;

/**
 * JMenuItem extension
 * @author pgi
 */
public class JMenuItemExt extends JMenuItem {

    /* Serial version of this class */
    private static final long serialVersionUID = 0;

    /**
     * Initializes this menu item with the given label
     * @param label the label of the menu item
     */
    public JMenuItemExt(String label) {
        super(label);
    }

    /**
     * Uses a runnable as callback called when this button fires an action event
     * @param task the callback
     * @return this
     */
    public JMenuItemExt onActionPerformed(Runnable task) {
        ExtUtilities.onActionPerformed(this, task);
        return this;
    }
    
    
    /**
     * Add an action listener to this control
     * @param al the listener
     * @return this
     */
    public JMenuItemExt withActionListener(ActionListener al) {
        addActionListener(al);
        return this;
    }
}
